using XSResearch.Configuration;
using XSResearch.Monitoring;
using XSResearch.Utilities;

namespace XSResearch
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                var config = AppConfig.Load();
                var logger = new AppLogger(config.LogPath);
                var errorHandler = new ErrorHandler(logger);
                using var monitor = new PerformanceMonitor(logger);

                logger.Log("Starting research system", LogLevel.Info);
                
                errorHandler.ExecuteWithRetry(() => 
                {
                    monitor.StartOperation("SystemInitialization");
                    InitializeSystem(config, logger);
                    monitor.EndOperation("SystemInitialization");
                    return true;
                }, OperationType.DataProcessing, "System init");

                RunResearchCycles(config, logger, monitor);
            }
            catch (OperationFailedException ex)
            {
                Console.WriteLine($"Fatal error: {ex.Message}");
                Environment.Exit(1);
            }
        }

        static void InitializeSystem(AppConfig config, AppLogger logger)
        {
            // 初始化代码...
        }

        static void RunResearchCycles(AppConfig config, AppLogger logger, PerformanceMonitor monitor)
        {
            // 研究周期代码...
        }
    }
}
